package kdone;

import java.util.Hashtable;

public class ProtocolKD_Define {
    
    public final int STATUS_NORMAL       = 0;
    public final int STATUS_RECEIVE      = 1;
    public final int STATUS_TRANSMIT     = 2;
    public final int STATUS_ANALYSIS     = 4;
    public final int STATUS_RECEIVE_OK   = 5;
    public final int STATUS_RECEIVE_FAIL = 6;
    
    public final int FORMAT_INDEX_STX       = 0;
    public final int FORMAT_INDEX_DEVICE    = 1;
    public final int FORMAT_INDEX_SUBID     = 2;
    public final int FORMAT_INDEX_COMMAND   = 3;
    public final int FORMAT_INDEX_LENGTH    = 4;
    public final int FORMAT_INDEX_TX_DEVICE = 5;
    public final int FORMAT_INDEX_RX_DEVICE = 6;
    public final int FORMAT_INDEX_TX_DONG   = 7;
    public final int FORMAT_INDEX_TX_DONG_H = 7;
    public final int FORMAT_INDEX_TX_DONG_L = 8;
    public final int FORMAT_INDEX_TX_HOO    = 9;
    public final int FORMAT_INDEX_TX_HOO_H  = 9;
    public final int FORMAT_INDEX_TX_HOO_L  = 10;
    public final int FORMAT_INDEX_RX_DONG   = 11;
    public final int FORMAT_INDEX_RX_DONG_H = 11;
    public final int FORMAT_INDEX_RX_DONG_L = 12;
    public final int FORMAT_INDEX_RX_HOO    = 13;
    public final int FORMAT_INDEX_RX_HOO_H  = 13;
    public final int FORMAT_INDEX_RX_HOO_L  = 14;
    public final int FORMAT_INDEX_CHANNEL   = 15;
    public final int FORMAT_INDEX_VEDIO     = 16;
    public final int FORMAT_INDEX_DATA      = 17;
    
    public final int FORMAT_DATA_STX        = 0xF7;

    
    //public final int FORMAT_INDEX_CHECK_SUM = 17;
    //public final int FORMAT_INDEX_ADD_SUM = 18;
    
    private static final int cntDevice = 26;
    private static final String[] strDevice = {
        "Main mDevice",
        "Home",
        "Lobby",
        "Guard",
        "Lobby+Guard",
        "RESERVE",
        "Sub mDevice1",
        "Sub mDevice2",
        "Sub mDevice3",
        "Sub mDevice4",
        "Sub mDevice5",
        "Sub mDevice6",
        "Sub mDevice",
        "Sub mDevice8",
        "Sub mDevice9",
        "Sub mDevice10",
        "Sub mDevice11",
        "Sub mDevice12",
        "Sub mDevice13",
        "Sub mDevice14",
        "Sub mDevice15",
        "All mDevice",
        "PC",
        "Ethernet",
        "Door Phone",
        "Sub Phone"
    };
    
    private static final Integer[] intDevice = {
        0x00,
        0x01,
        0x02,
        0x03,
        0x04,
        0x0F,
        0x11,
        0x12,
        0x13,
        0x14,
        0x15,
        0x16,
        0x17,
        0x18,
        0x19,
        0x1A,
        0x1B,
        0x1C,
        0x1D,
        0x1E,
        0x1F,
        0x20,
        0x30,
        0x40,
        0x50,
        0x51
    };
    

    private static final int cntCommand = 93;
    private static final String[] strCommand = {
        "CALL_ON",
        "CALL_OK",
        "CALL_BUSY",
        "TALK_ON",
        "ALL_OFF",
        "DIRECT_TALK_CONVERSION_TX",
        "GUARD_CONVERSION_CALL_REQUEST",
        "TALK_WAIT",
        "CALL_BUSY_ETC",
        "RESERVE",
        "RESERVE",
        "RESERVE",
        "RESERVE",
        "EXT_LINE_TEST_ON",
        "LINE_TEST_ON",
        "DOOR_OPEN",
        "FIRE_DOOR_OPEN",
        "FIRE_DOOR_CLOSE",
        "AUTO_CALL_REQUEST",
        "TEMINAL_ALIVE_REQUEST",
        "TEMINAL_ALIVE_TX",
        "TEMINAL_SETUP_INQUIRY",
        "TEMINAL_SETUP_TX",
        "TEMINAL_SETUP_CHANGE",
        "FACTORY_MODE_ENTER",
        "SECURITY_DATA_COM_REQUEST",
        "SECURITY_DATA_RESULT_TX",
        "FACTORY_MODE_INFO_TX",
        "PC_USE_LIMIT",
        "ERROR",
        "OUT",
        "HOME",
        "FIRE",
        "GAS",
        "EMERGENCY",
        "BURGALR1",
        "BURGALR2",
        "BURGALR3",
        "BURGALR4",
        "EVENT_RELEASE",
        "PARCEL_INFORM",
        "RESERVE",
        "RESERVE",
        "RESERVE",
        "EVENT_GUARD_CONVERSION",
        "EPASS_SETUP",
        "CPASS_SETUP",
        "RF_SETUP",
        "PHONE_SETUP",
        "SECURITY_INFO_INQUIRY",
        "SECURITY_INFO_TX",
        "MAIN_VERSION_INQUIRY",
        "MAIN_VERSION_TX",
        "EVENT_INFO_INQUIRY",
        "EVENT_INFO_DELETE",
        "EVENT_INFO_TX",
        "RESET_COUNT_DELETE",
        "RESET_COUNT_INQUIRY",
        "RESET_COUNT_INFO_TX",
        "MAIN_RESET",
        "APT_SETUP",
        "APT_INQUIRY",
        "APT_INFO_TX",
        "MAIN_INFO_SETUP",
        "MAIN_ INFO_INQUIRY",
        "MAIN_INFO_TX",
        "MEMORY_INITIAL",
        "MEMORY_BACKUP",
        "GUARD_CON_INQUIRY",
        "GUARD_CON_INQUIRY_TX",
        "SETUP_OK",
        "DELETE_OK",
        "SETUP_FAIL",
        "DELETE_FAIL",
        "INQUIRY_FAIL",
        "DONG_INFO_REQUEST",
        "DONG_INFO_TX",
        " CH_INFO_REQUEST",
        "CH_INFO_TX",
        "MONITER_REQUEST",
        "MONITER_DATA_TX",
        "TIME_INQ",
        "TIME_TX",
        "IP_SETUP",
        "IP_INQUIRY",
        "IP_INFO_TX",
        "SUB_TEMINAL_INFO _SETUP",
        "SUB_TEMINAL_INFO_INQUIRY",
        "SUB_TEMINAL_INFO _TX",
        "RESERVE",
        "ETHERNET_ID_SETUP",
        "ETHERNET_ID_INQUIRY",
        "ETHERNET_ID_TX"

    };
    
    private static final Integer[] intCommand = {
        0x01,
        0x02,
        0x03,
        0x04,
        0x05,
        0x06,
        0x07,
        0x08,
        0x09,
        0x0A,
        0x0B,
        0x0C,
        0x0D,
        0x0E,
        0x0F,
        0x11,
        0x12,
        0x13,
        0x14,
        0x15,
        0x16,
        0x17,
        0x18,
        0x19,
        0x1A,
        0x1B,
        0x1C,
        0x1D,
        0x1E,
        0x1F,
        0x21,
        0x22,
        0x23,
        0x24,
        0x25,
        0x26,
        0x27,
        0x28,
        0x29,
        0x2A,
        0x2B,
        0x2C,
        0x2D,
        0x2E,
        0x2F,
        0x31,
        0x32,
        0x33,
        0x34,
        0x35,
        0x36,
        0x37,
        0x38,
        0x39,
        0x3A,
        0x3B,
        0x3C,
        0x3D,
        0x3E,
        0x3F,
        0x41,
        0x42,
        0x43,
        0x44,
        0x45,
        0x46,
        0x47,
        0x48,
        0x49,
        0x4A,
        0x4B,
        0x4C,
        0x4D,
        0x4E,
        0x4F,
        0x51,
        0x52,
        0x53,
        0x54,
        0x55,
        0x56,
        0x57,
        0x58,
        0x59,
        0x5A,
        0x5B,
        0x5C,
        0x5D,
        0x5E,
        0x5F,
        0x61,
        0x62,
        0x63

    };


    private Hashtable<Integer,String> Device = new Hashtable<Integer,String>();
    private Hashtable<Integer,String> Command = new Hashtable<Integer,String>();
    
    public ProtocolKD_Define(){
        int i;

        for(i = 0 ; i < cntDevice; i++ ){
            Device.put(intDevice[i], strDevice[i]);
        }
        
        for(i = 0 ; i < cntCommand; i++ ){
            Command.put(intCommand[i], strCommand[i]);
        }        
    }
    
    public String GetDevice( Integer key ){
        return Device.get(key);
    }
    
    public String GetCommand( Integer key ){
        return Command.get(key);
    }
    
}
